Skip to content

fix(client): deduplicate mic.capture_report trace emissions#2189

Merged
oliverlaz merged 1 commit intomainfrom
fix/mic-capture-report-trace-dedup
Apr 8, 2026
Merged

fix(client): deduplicate mic.capture_report trace emissions#2189
oliverlaz merged 1 commit intomainfrom
fix/mic-capture-report-trace-dedup

Conversation

@oliverlaz
Copy link
Copy Markdown
Member

@oliverlaz oliverlaz commented Apr 7, 2026

💡 Overview

Reduces trace noise from mic.capture_report by only tracing when the capturesAudio value actually changes, rather than on every periodic emission during sustained silence. The internal dispatchEvent continues firing on every callback so downstream consumers are unaffected.

📝 Implementation notes

  • Added a lastCapturesAudio variable scoped to each no-audio detector instance inside MicrophoneManager.setup()
  • tracer.trace('mic.capture_report', ...) is now gated on capturesAudio !== lastCapturesAudio
  • streamClient.dispatchEvent(event) remains unconditional
  • The variable naturally resets when the detector is torn down on device switch or mic disable/re-enable, so the first emission from a new detector always traces

Summary by CodeRabbit

Release Notes

  • Refactor
    • Optimized microphone status tracking to reduce redundant trace events, improving logging clarity when audio capture status remains unchanged.

Only trace mic.capture_report when the capturesAudio value actually
changes, reducing noise from repeated emissions during sustained
silence. The internal dispatchEvent continues firing on every callback
so consumers are unaffected.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b1e1f9e-65bd-4292-8577-690beb51a416

📥 Commits

Reviewing files that changed from the base of the PR and between 649aea2 and 83cc62b.

📒 Files selected for processing (1)
  • packages/client/src/devices/MicrophoneManager.ts

📝 Walkthrough

Walkthrough

Added state tracking (lastCapturesAudio) to suppress redundant mic.capture_report tracing when audio capture status remains unchanged, while preserving unconditional event dispatching to streamClient.

Changes

Cohort / File(s) Summary
Audio Capture Tracing Optimization
packages/client/src/devices/MicrophoneManager.ts
Added stateful tracking to prevent redundant trace emissions when microphone capture status hasn't changed between invocations. Event dispatching logic remains unconditional.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hop, hop, mic's working clean,
No more traces in between,
Status unchanged, we stay hushed and still,
Less noise, more logs with bunny skill! 🎤✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(client): deduplicate mic.capture_report trace emissions' accurately and concisely describes the main change: deduplicating trace emissions for mic.capture_report.
Description check ✅ Passed The pull request description covers the overview and implementation notes from the template, explaining the problem, solution, and technical details comprehensively.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mic-capture-report-trace-dedup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@oliverlaz oliverlaz requested a review from jdimovska April 7, 2026 13:26
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

⚠️ No Changeset found

Latest commit: 83cc62b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@oliverlaz oliverlaz merged commit 152ae90 into main Apr 8, 2026
20 checks passed
@oliverlaz oliverlaz deleted the fix/mic-capture-report-trace-dedup branch April 8, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants